package arcade;

/**
 * Role Player
 * 
 * Objects in games have roles. Roles allow objects to be uniquely identified
 * within the game.
 * 
 * @author Alexander Schearer <aas11@duke.edu>
 * 
 */
public abstract class RolePlayer implements Identifiable, Trashable {

	private String myRole;

	private boolean isTrashed;

	public RolePlayer(String role) {
		myRole = role;
		isTrashed = false;
	}

	public String getRole() {
		return myRole;
	}

	/**
	 * Assign a new role
	 * 
	 * This allows objects to change roles at run time. This might be useful for
	 * changing the intersection responses of given pieces.
	 * 
	 * @param role
	 */
	public void assignRole(String role) {
		myRole = role;
	}

	/**
	 * Return whether a given role is the same as the one this object has
	 * 
	 * @param role
	 * @return
	 */
	public boolean equals(String role) {
		return myRole.equals(role);
	}

	/**
	 * Return whether role players play the same role
	 * 
	 * Two role players are equal provided they play the same role
	 * 
	 * @param r
	 * @return
	 */
	public boolean equals(RolePlayer r) {
		return myRole.equals(r.getRole());
	}

	public int compareTo(String o) {
		return myRole.compareTo(o);
	}

	public boolean isTrashed() {
		return isTrashed;
	}

	public void trash() {
		isTrashed = true;
	}
	
	@Override
	public String toString()
	{
		return myRole;
	}
}
